from openpyxl import load_workbook
import xlrd
import xlwt
import os

filename = 'F:\python\XU22\TEST\XU1.0系统测试用例-模板 - 副本.xlsx'
filename2 = 'F:\python\XU22\TEST\XU1.0系统测试用例-模板.xlsx'
filename3 = 'F:\python\XU22\TEST\\allcase.xlsx'
def replace_xls(sheetname):
    wb = load_workbook(filename)
    wb2 = load_workbook(filename2)

    ws = wb[sheetname]
    print(ws)
    ws2 = wb2[sheetname]
    print(ws2)

    # 两个for循环遍历整个excel的单元格内容
    for i,row in enumerate(ws.iter_rows()):
        for j,cell in enumerate(row):
            ws2.cell(row= i +1,column=j+1,value = cell.value)

    wb2.save(filename2)


sheetnames = ['vmware云硬盘&回收站_张银龙', 'vmware网络_张银龙']

# 遇到复制几十个sheet时候，很有必要写个循环
for sheetname in sheetnames:
    replace_xls(sheetname)

# def getSheetNum(self,fname):
#     global SheetNumber
#     workbook = xlrd.open_workbook(fname)
#     all_SheetList = workbook.sheet_names()
#     SheetNumber = len(all_SheetList)
#     # print('sheetNumber::',SheetNumber)
#     return SheetNumber



